using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("UserParameter", "", "Wicresoft.Messages.ConnectionString")]
    public class UserParameter : Info
    {
        #region SQL column name consts
        public const string SQLCOL_USERPARAMETERID = "UserParameterID";
        public const string SQLCOL_USERNAME = "UserName";
        public const string SQLCOL_PARAMETERKEY = "ParameterKey";
        public const string SQLCOL_DEVICEID = "DeviceID";
        public const string SQLCOL_PARAMETERVALUE = "ParameterValue";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public UserParameter() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public UserParameter(Guid UserParameterID)
        {
            this.UserParameterID = UserParameterID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            UserParameterID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_USERPARAMETERID]);
            UserName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_USERNAME]);
            ParameterKey = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PARAMETERKEY]);
            DeviceID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_DEVICEID]);
            ParameterValue = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_PARAMETERVALUE]);
        }

        #region Properties
        #region Property <Guid> UserParameterID
        [Property("UserParameterID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid UserParameterID
        {
            get { return _UserParameterID; }
            set { _UserParameterID = value; }
        }
        private Guid _UserParameterID = Guid.Empty;
        #endregion

        #region Property <string> UserName
        [Property("UserName", 100, SqlDbType.NVarChar, false, false)]
        public string UserName
        {
            get { return _UserName; }
            set { _UserName = value; }
        }
        private string _UserName = null;
        #endregion

        #region Property <string> ParameterKey
        [Property("ParameterKey", 100, SqlDbType.NVarChar, false, false)]
        public string ParameterKey
        {
            get { return _ParameterKey; }
            set { _ParameterKey = value; }
        }
        private string _ParameterKey = null;
        #endregion

        #region Property <int> DeviceID
        [Property("DeviceID", 4, SqlDbType.Int, false, false)]
        public int DeviceID
        {
            get { return _DeviceID; }
            set { _DeviceID = value; }
        }
        private int _DeviceID = int.MinValue;
        #endregion

        #region Property <string> ParameterValue
        [Property("ParameterValue", 400, SqlDbType.NVarChar, false, false)]
        public string ParameterValue
        {
            get { return _ParameterValue; }
            set { _ParameterValue = value; }
        }
        private string _ParameterValue = null;
        #endregion
        #endregion




    }
}
